#include "Plane.h"
#include "Common.h"

namespace Pandora
{
	int CPlane::Intersect(CRay& ray, float &t)
	{
		float temp = normal.Dot(ray.GetDirection());
		if(temp < 0.0f)
		{
			float t0 = -(normal.Dot(ray.GetStartPoint()) + d )/temp;
			if(t0 > 0.1f && t0 < t)
			{
				t = t0;
				return HIT;
			}
		}
		return MISS;
	}

	int CPlane::Intersect(CRay* ray, float &t)
	{
		return Intersect(*ray, t);
	}

}; //namespace Pandora